from django.db import models


class Survey(models.Model):
    """企业信息安全审计问卷"""
    
    # 基本信息
    company_name = models.CharField(max_length=200, verbose_name='公司名称（全称）')
    employee_count = models.CharField(max_length=50, verbose_name='员工人数')
    main_business = models.TextField(verbose_name='主营业务')
    security_risk = models.CharField(max_length=100, verbose_name='最担心的安全风险')
    security_risk_other = models.CharField(max_length=200, blank=True, verbose_name='其他安全风险')
    security_incident = models.CharField(max_length=10, verbose_name='是否发生过安全事件')
    security_incident_detail = models.TextField(blank=True, verbose_name='安全事件具体情况')
    audit_expectation = models.TextField(verbose_name='期望通过审计解决什么问题')
    
    # 组织管理
    security_policy = models.CharField(max_length=50, verbose_name='是否制定了信息安全相关制度')
    security_officer = models.CharField(max_length=10, verbose_name='是否指定了信息安全责任人')
    security_officer_position = models.CharField(max_length=100, blank=True, verbose_name='安全责任人职位')
    
    # 人员管理
    it_team_size = models.CharField(max_length=50, verbose_name='IT团队人数')
    it_team_division = models.TextField(verbose_name='IT团队分工')
    it_outsource = models.CharField(max_length=10, verbose_name='是否有IT外包')
    it_outsource_scope = models.TextField(blank=True, verbose_name='IT外包范围')
    security_staff = models.CharField(max_length=10, verbose_name='是否有专门负责安全的人')
    security_staff_name = models.CharField(max_length=100, blank=True, verbose_name='安全负责人姓名')
    confidentiality_agreement = models.CharField(max_length=50, verbose_name='新员工是否签署保密协议')
    account_revoke = models.CharField(max_length=50, verbose_name='员工离职账号权限处理')
    security_training = models.CharField(max_length=50, verbose_name='是否开展信息安全培训')
    security_training_freq = models.CharField(max_length=100, blank=True, verbose_name='安全培训频率')
    
    # 物理环境
    visitor_management = models.CharField(max_length=50, verbose_name='外来人员如何管理')
    important_area_control = models.CharField(max_length=50, verbose_name='财务室机房等是否单独管控')
    device_borrow = models.CharField(max_length=50, verbose_name='公司设备是否有借用管理')
    
    # 基础设施
    important_systems = models.TextField(verbose_name='重要系统列表')
    deployment_mode = models.CharField(max_length=50, verbose_name='系统部署方式')
    database_type = models.CharField(max_length=100, verbose_name='数据库类型')
    database_type_other = models.CharField(max_length=100, blank=True, verbose_name='其他数据库类型')
    network_planning = models.CharField(max_length=50, verbose_name='办公网络规划')
    remote_work = models.CharField(max_length=50, verbose_name='员工如何远程办公')
    internet_exit_count = models.CharField(max_length=50, verbose_name='互联网出口数量')
    internet_bandwidth = models.CharField(max_length=50, verbose_name='互联网带宽')
    data_backup = models.CharField(max_length=50, verbose_name='重要数据如何备份')
    
    # 系统字段
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        db_table = 'survey'
        verbose_name = '信息安全审计问卷'
        verbose_name_plural = '信息安全审计问卷'
        ordering = ['-created_at']

    def __str__(self):
        return f"{self.company_name}"
